package com.heima.wemedia.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Mq {
    @Bean
    public Queue ttlQueue() {
        return QueueBuilder
                .durable("ttl.queue") // 指定队列名称，并持久化
                .deadLetterExchange("dl.ttl.direct") // 指定死信交换机
                .deadLetterRoutingKey("DD")
                .build();
    }

    @Bean
    public DirectExchange ttlExchange() {
        return new DirectExchange("ttl.direct");
    }

    @Bean
    public Binding ttlBinding() {
        return BindingBuilder.bind(ttlQueue()).to(ttlExchange()).with("ttl");
    }

    //    死信队列
    @Bean
    public Queue deadQueue() {
        return new Queue("dl.ttl.queue", true);
    }

    @Bean
    public DirectExchange deadExchange() {
        return new DirectExchange("dl.ttl.direct");
    }

    @Bean
    public Binding deadBinding() {
        return BindingBuilder.bind(deadQueue()).to(deadExchange()).with("DD");
    }

    @Bean
    public Queue dd() {
        return new Queue("pop");
    }


    //文章修改MQ
    @Bean
    public Queue wmQueue() {
        return new Queue("wm.queue", true);
    }

    @Bean
    public DirectExchange wmExchange() {
        return new DirectExchange("wm.direct");
    }

    @Bean
    public Binding wmBinding() {
        return BindingBuilder.bind(wmQueue()).to(wmExchange()).with("wm");
    }


}
